package common.util.digestUtils.base64;

import org.apache.commons.codec.binary.Base64;

public class ImoocBase64 {

    private static String src = "imooc security base64";

    public static void main(String[] args) {
        jdkBase64();
        commonsCodesBase64();
    }

    public static void jdkBase64() {

        String encode = Base64.encodeBase64String(src.getBytes());
            System.out.println("encode : " + encode);
        System.out.println("decode : " + Base64.encodeBase64String(encode.getBytes()));

    }

    public static void commonsCodesBase64() {
        byte[] encodeBytes = Base64.encodeBase64(src.getBytes());
        System.out.println("encode : " + new String(encodeBytes));

        byte[] decodeBytes = Base64.decodeBase64(encodeBytes);
        System.out.println("decode : " + new String(decodeBytes));
    }


}
